﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.OracleClient;
using CardLogistics.Model.Sys;

namespace CardLogistics.DAL.Sys
{
    /// <summary>
    /// 数据访问类:Sys_Log
    /// </summary>
    public class Sys_LogData
    {
        public Sys_LogData()
        { }
        #region  新增
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>返回插入数据的编号</returns>
        public string Add(Sys_Log model)
        {
            OracleParameter[] parameters = {
					new OracleParameter("vOut", OracleType.Number),
					new OracleParameter("UserID", OracleType.VarChar),
					new OracleParameter("LoginIP", OracleType.VarChar),
					new OracleParameter("LogDate", OracleType.DateTime),
					new OracleParameter("LogContent", OracleType.VarChar),
					new OracleParameter("LogType", OracleType.VarChar)};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.LoginIP;
            parameters[3].Value = model.LogDate;
            parameters[4].Value = model.LogContent;
            parameters[5].Value = model.LogType;

            return DbHelperSQL.RunProcedure("P_Sys_Log_ADD", parameters, parameters[0]).ToString();
        }
        #endregion

        #region 删除
        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="ID">删除信息ID</param>
        /// <returns>删除成功返回True。否则返回false</returns>
        public int Delete(string ID)
        {
            try
            {
                return DbHelperSQL.ExecuteSql(" DELETE FROM Sys_Log WHERE ID='"+ID+"'");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

   

        #region 根据条件查询相应的表的字段
        /// <summary>
        /// 根据条件查询相应的表的字段
        /// </summary>
        /// <param name="StrWhere">查询条件</param>
        /// <param name="StrFields">要查询的字段</param>
        /// <returns>填充完数据的DataTable</returns>
        public DataTable GetList(string StrWhere, string StrFields,string orderStr)
        {
            return CommonData.GetListOrderBy(StrWhere, "v_sys_log", StrFields, orderStr, 0);
        }
        #endregion
    }
}

